﻿using Microsoft.Owin.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

namespace ldhWebApi
{
    class Program
    {
        public static IDisposable SignalR { get; set; }

        static void Main()
        {
            bool local = true;

            if (local)
            {
                string baseAddress = "http://localhost:8089/";
                Task.Run(() =>
                {
                    WebApp.Start<WebApi>(url: baseAddress);
                    Console.WriteLine("WebApi Server is run in " + baseAddress);
                });
                string ServerURI = "http://localhost:8080/";
                Task.Run(() =>
                {
                    SignalR = WebApp.Start<Startup_Signalr>(url: ServerURI);
                    Console.WriteLine("Signalr Server is run in " + ServerURI);
                });
            }
            else
            {
                Task.Run(() =>
                {
                    var options = new StartOptions("http://*:8089")
                    {
                        ServerFactory = "Microsoft.Owin.Host.HttpListener"
                    };
                    WebApp.Start<WebApi>(options);
                    Console.WriteLine("WebApi Server is run in http://*:8089");
                });

                Task.Run(() =>
                {
                    var options = new StartOptions("http://*:8080")
                    {
                        ServerFactory = "Microsoft.Owin.Host.HttpListener"
                    };
                    SignalR = WebApp.Start<Startup_Signalr>(options);
                    Console.WriteLine("Signalr Server is run in http://*:8080");
                });
            }

            Console.ReadLine();

            SignalR.Dispose();

        }

    }
}
